﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BT_BieuThuc_Nhom13.Expressions
{
    public class MultipliableExpr : BinaryExpr
    {
        public MultipliableExpr(Expression _expr1, Expression _expr2)
        {
            expr1 = _expr1;
            expr2 = _expr2;
        }

        public override double Evaluate(double x)
        {
            return expr1.Evaluate(x) * expr2.Evaluate(x);
        }

        protected override Expression CreateDerive()
        {
            return new AdditiveExpr(new MultipliableExpr(expr1.Derive(), expr2),
                              new MultipliableExpr(expr1, expr2.Derive()));
        }

        protected override string Operator()
        {
            return "*";
        }
    }
}
